<!DOCTYPE html>
<html>
<head>
    <title>${sysEn}-配件类别列表</title>
     <#include "/common/com_css.ftl" >
</head>
<body>
    <div id="wrapper">
        <!----左侧导航开始----->
        <#include "/common/menu.ftl">
        <!----左侧导航结束----->

        <!---右侧内容区开始---->
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <#include "/common/con_nav.ftl">
            <@con_nav_tag current="配件类别列表"></@con_nav_tag>
            <!-- 检索条件开始 -->
            <div class="ibox-content m-b-sm border-bottom">
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-form-label" for="status">状态</label>
                            <select class="form-control m-b" name="status" id="status">
                                <option value="">不限</option>
                                <option value="1">启用</option>
                                <option value="0">停用</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-2">
                        <div class="form-group">
                            <label class="col-form-label" for="categoryName">配件类别名称</label>
                            <input type="text" id="categoryName" name="categoryName" value="" placeholder="" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="text-left">
                    <input type="button" name="" class="btn btn-primary" value="提交" id="btnSubmit"></input>
                </div>
            </div>
            <!-- 检索条件结束 -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox ">
                        <div class="ibox-content">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="example" >
                                </table>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
            <#include "/common/footer.ftl">
        </div>
        <!---右侧内容区结束---->
     </div>
    <#include "/common/com_table_js.ftl">
    <script>
        $(document).ready(function() {
            var table =  ListPageManager.DataTable.init({
                ajax:{
                    url:"${ctx}/parts_category_list_page.do"
                },
                ajaxParam:function(){
                    var obj = {};
                    if($("#status").val()) {
                        obj["status"] = $("#status").val();
                    }
                    if($("#categoryName").val()) {
                        obj["categoryName"] = $("#categoryName").val();
                    }
                    return obj;
                },
                buttons:[{cmd:'add'},{cmd:'del',text:'删除',action:function (cmd,e,dt,node,config,tgobj) {
                        var data = {"ids":tgobj.checkIds};
                        ListPageManager.Tools.ajax({
                            url:"${ctx}/parts_category_del.do",
                            data:data,
                            success:function (e) {
                                if(e.success){
                                    ListPageManager.Popup.msg("删除成功",{},function () {
                                        tgobj.redraw();
                                    });
                                }else{
                                    ListPageManager.Popup.msg(e.message);
                                }
                            }
                        });

                    }}],
                addUrl:function(){return "${ctx}/parts_category_edit.do"},
                updUrl:function(row,data,dataIndex){return "${ctx}/parts_category_edit.do?id=" + data.id; },
                deleteUrl:function(row,data,dataIndex){return "${ctx}/parts_category_del.do?ids[]=" + data.id},
                rowCreatedCall:function(row,data,dataIndex){},
                withCheckColumn:{flg:true,key:"id"},
                columns:[
                    {title:"序号",data:"id"},
                    {title:"配件类别",data:"categoryName"},
                    {title:"描述",data:"remarks"},
                    {title:"状态",render:function (ctx,status,data) {
                        if(data.status == 1){
                            return "启用";
                        }else{
                            return "停用";
                        }
                        }},
                    {title:"排序",data:"sort"},
                    {title:"预览图片",data:"imageUrl",render:function(ctx,data){
                    		return "<img src=" + ctx + " height='35' width='120' />";
                    	
                    	}
                    },
                    {title:"热门标签",render:function (ctx,status,data) {
                        if(data.isHot == 1){
                            return "是";
                        }else{
                            return "否";
                        }
                        }},
                    {title:"创建人",data:"createBy"},
                    {title:"创建时间",render:function (data,type,row) {
                            return ListPageManager.Tools.formatDate(row["createTime"]);
                        }},
                    {title:"修改人",data:"updateBy"},
                    {title:"修改时间",render:function (data,type,row) {
                            return ListPageManager.Tools.formatDate(row["updateTime"]);
                    }},
                    {title:"",toolcolinfo:[{"cmd":"status",gettext:function(data,type,row){
                               if(row.status == 1){
                                   return "停用";
                               }else{
                                   return "启用";
                               }
                            },click:function(cmd,row,data,dataIndex){
                                var stat = data.status?0:1;

                                ListPageManager.Tools.ajax({
                                   url:"${ctx}/parts_category_status.do",
                                    type:"post",
                                    data:{status:stat,id:data.id},
                                    success:function (e) {
                                       if(e.success){
                                           table.redraw();
                                       }else{
                                           ListPageManager.Popup.msg(e.message);
                                       }
                                    }
                                });
                               var j =0 ;
                            }},{cmd:"upd"},{"cmd":"del"}]}
                ]
            },$("#example"));
            $("#btnSubmit").on("click",function(){
                table.redraw();
            });
        });
    </script>
</body>
</html>
